package cn.dslcode.security.config.handler;

import cn.dslcode.common.web.WebUtil;
import cn.dslcode.common.web.response.RestResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author dongsilin
 * @version 2018/4/8.
 *          登出成功后的处理
 */
@Slf4j
@Component
public final class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler {

    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        log.info("*******************LogoutSuccessHandler");
        WebUtil.output(response, RestResponse.buildSuccess(), WebUtil.ResponseOutputType.JSON);
    }

}